﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using XXX.Models.XXXEntities;
using XXX.Bo;

// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860

namespace XXX.api.Controllers
{
    [Route("api/wms/[controller]")]
    [ApiController]
    //[Authorize]
    public class PU_GetPuArrivalController : ControllerBase
    {
        //private readonly IKuCunReqRepository _invRepository;
        private readonly ILogger<PU_GetPuArrivalController> _logger;
        public PU_GetPuArrivalController(ILogger<PU_GetPuArrivalController> logger)
        {
            //_invRepository = xxxRepository;
            _logger = logger;
        }

        /// <summary>
        /// ccode =0，代表全部
        /// </summary>
        /// <param name="ccode"></param>
        /// <returns></returns>
        [HttpGet]
        public Models.RetModel Get(string corg,string cwhcode,string ccode)
        {
            Models.RetModel ret = DBService.PU_GetPuArrival(corg, cwhcode,ccode);

            return ret;
            //return ReturnStd.Success(jsonstr);
        }
         
    }

    /// <summary>
    /// 采购退货
    /// </summary>
    [Route("api/wms/[controller]")]
    [ApiController]
    //[Authorize]
    public class PU_GetPuArrival2Controller : ControllerBase
    {
        //private readonly IKuCunReqRepository _invRepository;
        private readonly ILogger<PU_GetPuArrival2Controller> _logger;
        public PU_GetPuArrival2Controller(ILogger<PU_GetPuArrival2Controller> logger)
        {
            //_invRepository = xxxRepository;
            _logger = logger;
        }

        /// <summary>
        /// ccode =0，代表全部
        /// </summary>
        /// <param name="ccode"></param>
        /// <returns></returns>
        [HttpGet]
        public Models.RetModel Get(string corg, string cwhcode,string ccode)
        {
            Models.RetModel ret = DBService.PU_GetPuArrival2(corg, cwhcode,ccode);

            return ret;
            //return ReturnStd.Success(jsonstr);
        }


        //[HttpPost]
        //public Models.RetModel Post([FromBody]Models.XXXEntities.KuCunReq model)
        //{

        //    //_logger.LogInformation(model);
        //    Models.RetModel ret = _invRepository.AddReq(model);

        //    return ret;
        //}
    }



    [Route("api/wms/[controller]")]
    [ApiController]
    //[Authorize]
    public class GetPuArrivalQCController : ControllerBase
    {
        //private readonly IKuCunReqRepository _invRepository;
        private readonly ILogger<GetPuArrivalQCController> _logger;
        public GetPuArrivalQCController(ILogger<GetPuArrivalQCController> logger)
        {
            //_invRepository = xxxRepository;
            _logger = logger;
        }

        /// <summary>
        /// ccode =0，代表全部
        /// </summary>
        /// <param name="ccode"></param>
        /// <returns></returns>
        [HttpGet]
        public Models.RetModel Get(string ccode)
        {
            Models.RetModel ret = DBService.GetPuArrivalQC(ccode);

            return ret;
            //return ReturnStd.Success(jsonstr);
        }


        //[HttpPost]
        //public Models.RetModel Post([FromBody]Models.XXXEntities.KuCunReq model)
        //{

        //    //_logger.LogInformation(model);
        //    Models.RetModel ret = _invRepository.AddReq(model);

        //    return ret;
        //}
    }
    /// <summary>
    /// 到货拒收
    /// </summary>
    [Route("api/wms/[controller]")]
    [ApiController]
    //[Authorize]
    public class GetPuArrivalRefuseController : ControllerBase
    {
        //private readonly IKuCunReqRepository _invRepository;
        private readonly ILogger<GetPuArrivalRefuseController> _logger;
        public GetPuArrivalRefuseController(ILogger<GetPuArrivalRefuseController> logger)
        {
            //_invRepository = xxxRepository;
            _logger = logger;
        }

        /// <summary>
        /// ccode =0，代表全部
        /// </summary>
        /// <param name="ccode"></param>
        /// <returns></returns>
        [HttpGet]
        public Models.RetModel Get(string ccode)
        {
            Models.RetModel ret = DBService.GetPuArrivalRefuse(ccode);

            return ret;
            //return ReturnStd.Success(jsonstr);
        }


        //[HttpPost]
        //public Models.RetModel Post([FromBody]Models.XXXEntities.KuCunReq model)
        //{

        //    //_logger.LogInformation(model);
        //    Models.RetModel ret = _invRepository.AddReq(model);

        //    return ret;
        //}
    }

   
    

    /// <summary>
    /// 根据到货单生成入库单
    /// </summary>
    [Route("api/wms/[controller]")]
    [ApiController]
    //[Authorize]
    public class PU_ArrToRd01Controller : ControllerBase
    {
        //private readonly IKuCunReqRepository _invRepository;
        private readonly ILogger<PU_ArrToRd01Controller> _logger;
        public PU_ArrToRd01Controller(ILogger<PU_ArrToRd01Controller> logger)
        {
            //_invRepository = xxxRepository;
            _logger = logger;
        }


        [HttpPost]
        public Models.RetModelbool Post(PuArrivalBarcode model)
        {

            Models.RetModelbool ret = WMSService.PU_ArrToRd01(model);

            return ret;
            //return ReturnStd.Success(jsonstr);
        }

    }

    
    /// <summary>
    /// 根据到货检验单生成入库单
    /// </summary>
    [Route("api/wms/[controller]")]
    [ApiController]
    //[Authorize]
    public class PuArrQCToRd01Controller : ControllerBase
    {
        //private readonly IKuCunReqRepository _invRepository;
        private readonly ILogger<PuArrQCToRd01Controller> _logger;
        public PuArrQCToRd01Controller(ILogger<PuArrQCToRd01Controller> logger)
        {
            //_invRepository = xxxRepository;
            _logger = logger;
        }


        [HttpPost]
        public Models.RetModelbool Post(PuArrivalBarcode model)
        {

            Models.RetModelbool ret = WMSService.PuArrQCToRd01(model);

            return ret;
            //return ReturnStd.Success(jsonstr);
        }

    }
    


    /// <summary>
    /// 查询srm里的送货单
    /// </summary>
    [Route("api/wms/[controller]")]
    [ApiController]
    //[Authorize]
    public class GetSongHuoController : ControllerBase
    {
        //private readonly IKuCunReqRepository _invRepository;
        private readonly ILogger<GetSongHuoController> _logger;
        public GetSongHuoController(ILogger<GetSongHuoController> logger)
        {
            //_invRepository = xxxRepository;
            _logger = logger;
        }

        /// <summary>
        /// ccode =0，代表全部
        /// </summary>
        /// <param name="ccode"></param>
        /// <returns></returns>
        [HttpGet]
        public Models.RetModel Get(string ccode)
        {
            Models.RetModel ret =SRMService.GetSongHuo(ccode);

            return ret;
            //return ReturnStd.Success(jsonstr);
        } 
    }


    /// <summary>
    /// 查询srm里的送货单的条码
    /// </summary>
    [Route("api/wms/[controller]")]
    [ApiController]
    //[Authorize]
    public class GetSongHuoBarcodeController : ControllerBase
    {
        //private readonly IKuCunReqRepository _invRepository;
        private readonly ILogger<GetSongHuoBarcodeController> _logger;
        public GetSongHuoBarcodeController(ILogger<GetSongHuoBarcodeController> logger)
        {
            //_invRepository = xxxRepository;
            _logger = logger;
        }

        /// <summary>
        /// ccode =0，代表全部
        /// </summary>
        /// <param name="ccode"></param>
        /// <returns></returns>
        [HttpGet]
        public Models.RetModel Get(string ccode)
        {
            Models.RetModel ret = SRMService.GetSongHuoBarcode(ccode);

            return ret;
            //return ReturnStd.Success(jsonstr);
        }
    }

    

   
 

}
